home *** CD-ROM | disk | FTP | other *** search
- /*******************************************
- *
- * interior_outline(...
- *
- * This function produces the outline of
- * any "holes" inside an object. The
- * method is:
- * output = erosion of input
- * final output = input - output
- *
- *******************************************/
-
- interior_outline(in_name, out_name, the_image,
- out_image, il, ie, ll, le, value,
- mask_type)
- char in_name[], out_name[];
- int il, ie, ll, le;
- short the_image[ROWS][COLS],
- out_image[ROWS][COLS],
- mask_type, value;
- {
- int a, b, count, i, j, k;
- short mask[3][3], max;
- int length, width;
- struct tiff_header_struct image_header;
-
- /**************************************
- *
- * Copy the 3x3 erosion-dilation mask
- * specified by the mask_type.
- *
- ***************************************/
-
- switch(mask_type){
- case 1:
- copy_3_x_3(mask, edmask1);
- break;
- case 2:
- copy_3_x_3(mask, edmask2);
- break;
- case 3:
- copy_3_x_3(mask, edmask3);
- break;
- case 4:
- copy_3_x_3(mask, edmask4);
- break;
- default:
- printf("\nInvalid mask type, using mask 4");
- copy_3_x_3(mask, edmask4);
- break;
- }
-
- if(does_not_exist(out_name)){
- printf("\n\n output file does not exist %s", out_name);
- read_tiff_header(in_name, &image_header);
- round_off_image_size(&image_header,
- &length, &width);
- image_header.image_length = length*ROWS;
- image_header.image_width = width*COLS;
- create_allocate_tiff_file(out_name, &image_header,
- out_image);
- } /* ends if does_not_exist */
-
- read_tiff_image(in_name, the_image, il, ie, ll, le);
-
- mask_erosion(in_name, out_name, the_image,
- out_image, il, ie, ll, le,
- value, mask_type);
-
- for(i=0; i<ROWS; i++)
- for(j=0; j<COLS; j++)
- the_image[i][j] =
- the_image[i][j] - out_image[i][j];
-
- write_array_into_tiff_image(out_name, the_image,
- il, ie, ll, le);
-
- } /* ends interior_outline */
-
-
-
-
-
- /*******************************************
- *
- * exterior_outline(...
- *
- * This function produces the outline of
- * exterior of an object. The
- * method is:
- * output = dilation of input
- * final output = output - input
- *
- *******************************************/
-
- exterior_outline(in_name, out_name, the_image, out_image,
- il, ie, ll, le, value, mask_type)
- char in_name[], out_name[];
- int il, ie, ll, le;
- short the_image[ROWS][COLS],
- out_image[ROWS][COLS],
- mask_type, value;
- {
- int a, b, count, i, j, k;
- short mask[3][3], max;
- int length, width;
- struct tiff_header_struct image_header;
-
- /**************************************
- *
- * Copy the 3x3 erosion-dilation mask
- * specified by the mask_type.
- *
- ***************************************/
-
- switch(mask_type){
- case 1:
- copy_3_x_3(mask, edmask1);
- break;
- case 2:
- copy_3_x_3(mask, edmask2);
- break;
- case 3:
- copy_3_x_3(mask, edmask3);
- break;
- case 4:
- copy_3_x_3(mask, edmask4);
- break;
- default:
- printf("\nInvalid mask type, using mask 4");
- copy_3_x_3(mask, edmask4);
- break;
- }
-
- if(does_not_exist(out_name)){
- printf("\n\n output file does not exist %s", out_name);
- read_tiff_header(in_name, &image_header);
- round_off_image_size(&image_header,
- &length, &width);
- image_header.image_length = length*ROWS;
- image_header.image_width = width*COLS;
- create_allocate_tiff_file(out_name, &image_header,
- out_image);
- } /* ends if does_not_exist */
-
- read_tiff_image(in_name, the_image, il, ie, ll, le);
-
- mask_dilation(in_name, out_name, the_image,
- out_image, il, ie, ll, le,
- value, mask_type);
-
- for(i=0; i<ROWS; i++)
- for(j=0; j<COLS; j++)
- the_image[i][j] =
- out_image[i][j] - the_image[i][j];
-
- write_array_into_tiff_image(out_name, the_image,
- il, ie, ll, le);
-
- } /* ends exterior_outline */
-
-
-